package com.qf.controller;

import com.qf.constant.RabbitMQConstants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * 发送延时消息
 * @author dell
 * @version V1.0
 * @Date 2022/6/2 17:25:14
 */
@RestController
@RequestMapping("/mq")
public class MessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送延时消息
     */
    @GetMapping("/sendDelayMessage")
    public String send(){
        rabbitTemplate.convertAndSend(RabbitMQConstants.TOPIC_PUSH_SMS_REPORT+"_exchange", "routingKey","延时消息" ,(message)->{
            message.getMessageProperties().setDelay(1000*60*2);
            return message;
        });
        return "OK";
    }

}
